/**
 * 自定义接口
 * */


//投资列表
function getPortfolioList(){
    $.ajax({
        type: apis.portfolioList.method,
        url: apis.portfolioList.url,
        data: {},
        success: function (res) {
            console.log(res);
            if (res.code < 0) {
                return
            }
            var d = res.data, key;
            for (var i = 0; i < d.length; i ++) {
                key = d[i].fkey;
                if (d[i].ftype == 3) {
                    $('#' + key).attr('src', d[i].fval);
                } else if (d[i].ftype == 4) {
                    partList({k: key, v: d[i].fval});
                } else {
                    $('#' + key).html(d[i].fval);
                }
            }
        },
        error: function () {
            console.log('错误辣');
        }
    });
}


//数据列表
function partList(e){
    var d = e.v, key = e.k;
    var h = '', i;
    for (i = 0; i < d.length; i ++) {
        h += '<div class="col-xl-5 col-md-6">';
        h += '<div class="tf__featured_work_item">';
        h += '<a href="portfolio_details.html" class="cursor-arrow tf__featured_work_item_img">';
        h += '<div data-animation="img-blur">';
        //h += '<img src="images/futured_work_img_3.jpg" alt="futured" class="img-fluid w-100"/>';
        h += '<img src="' + d[i][0] + '" alt="futured" class="img-fluid w-100"/>';
        h += '</div>';
        h += '</a>';
        h += '<a href="portfolio_details.html">';
        h += '<h3 data-text-animation data-split="word">';
        h +=  d[i][1];
        h += '</h3>';
        h += '</a>';
        h += '<p data-text-animation="slide-from-right" data-split="char">';
        h +=  d[i][2];
        h += '</p>';
        h += '</div>';
        h += '</div>';
    }
    $('#' + key).html(h);
}


//投资网格
function getPortfolioGrid(){
    $.ajax({
        type: apis.portfolioGrid.method,
        url: apis.portfolioGrid.url,
        data: {},
        success: function (res) {
            console.log(res);
            if (res.code < 0) {
                return
            }
            var d = res.data, key;
            for (var i = 0; i < d.length; i ++) {
                key = d[i].fkey;
                if (d[i].ftype == 3) {
                    $('#' + key).attr('src', d[i].fval);
                } else if (d[i].ftype == 4) {
                    gridList({k: key, v: d[i].fval});
                } else {
                    $('#' + key).html(d[i].fval);
                }
            }
        },
        error: function () {
            console.log('错误辣');
        }
    });
}


//网格数据
function gridList(e){
    var d = e.v, key = e.k;
    var h = '', i;
    for (i = 0; i < d.length; i ++) {
        h += '<div class="col-xl-5 col-md-6">';
        h += '<div class="tf__featured_work_item">';
        h += '<a href="portfolio_details.html" class="cursor-arrow tf__featured_work_item_img">';
        h += '<div data-animation="img-blur">';
        //h += '<img src="images/futured_work_img_7.jpg" alt="futured" class="img-fluid w-100"/>';
        h += '<img src="' + d[i][0] + '" alt="futured" class="img-fluid w-100"/>';
        h += '</div>';
        h += '</a>';
        h += '<a href="portfolio_details.html">';
        h += '<h3 data-text-animation="rotate-in" data-split="line" data-duration="1">';
        //h += 'Website Design 2024';
        h += d[i][1];
        h += '</h3>';
        h += '</a>';
        //h += '<p>Website Design / Brand</p>';
        h += '<p>' + d[i][2] + '</p>';
        h += '</div>';
        h += '</div>';
    }
    $('#' + key).html(h);
}


//投资详情
function getPortfolioDetail(){
    $.ajax({
        type: apis.portfolioDetail.method,
        url: apis.portfolioDetail.url,
        data: {},
        success: function (res) {
            console.log(res);
            if (res.code < 0) {
                return
            }
            var d = res.data, key;
            for (var i = 0; i < d.length; i ++) {
                key = d[i].fkey;
                if (d[i].ftype == 3) {
                    $('#' + key).attr('src', d[i].fval);
                } else if (d[i].ftype == 4) {
                    if (d[i].id == 171) {
                        detailPort1({k: key, v: d[i].fval});
                    }
                    if (d[i].id == 172) {
                        detailPort2({k: key, v: d[i].fval});
                    }
                } else {
                    $('#' + key).html(d[i].fval);
                }
            }
        },
        error: function () {
            console.log('错误辣');
        }
    });
}


//详情1数据
function detailPort1(e){
    var d = e.v[0], key = e.k;
    var h = '', i;
    h += '<h4>' + d[0] + '</h4>';
    h += '<ul>';
    h += '<li>';
    h += '<h5>' + d[1] + '</h5>';
    h += '<p>' + d[2] + '</p>';
    h += '</li>';
    h += '<li>';
    h += '<h5>' + d[3] + '</h5>';
    h += '<p>' + d[4] + '</p>';
    h += '</li>';
    h += '<li>';
    h += '<h5>' + d[5] + '</h5>';
    h += '<p>' + d[6] + '</p>';
    h += '</li>';
    h += '<li>';
    h += '<h5>' + d[7] + '</h5>';
    h += '<p>' + d[8] + '</p>';
    h += '</li>';
    h += '<li>';
    h += '<h5>' + d[9] + '</h5>';
    h += '<p>' + d[10] + '</p>';
    h += '</li>';
    h += '<li>';
    h += '<p class="rating">';
    h += '<i class="fas fa-star"></i>';
    h += '<i class="fas fa-star"></i>';
    h += '<i class="fas fa-star"></i>';
    h += '<i class="fas fa-star"></i>';
    h += '<i class="fas fa-star"></i>';
    h += '</p>';
    h += '</ul>';
    console.log(h);
    $('#' + key).html(h);
}


//详情2数据
function detailPort2(e){
    var d = e.v, key = e.k;
    var h = '', i;
    for (i = 0; i < d.length; i ++) {
        h += '<div class="col-xl-6 col-md-6 grid_item">';
        h += '<div class="tf__featured_work_item tf__featured_work_item_small">';
        h += '<a href="#" class="cursor-arrow tf__featured_work_item_img">';
        h += '<div data-animation="img-blur">';
        //h += '<img src="images/futured_work_img_5.jpg" alt="futured" class="img-fluid w-100"/>';
        h += '<img src="' + d[i][0] + '" alt="futured" class="img-fluid w-100"/>';
        h += '</div>';
        h += '</a>';
        //h += '<h3 data-text-animation data-split="line" data-duration=".5">Corporate Website</h3>';
        h += '<h3 data-text-animation data-split="line" data-duration=".5">' + d[i][1] + '</h3>';
        //h += '<p>Website Design / Brand</p>';
        h += '<p>' + d[i][2] + '</p>';
        h += '</div>';
    }
    $('#' + key).html(h);
}